#!/usr/bin/env ruby
#encoding: utf-8
require "open-uri"
require "nokogiri"


class QiuBai
  def self.print(page)
    url = "http://www.qiushibaike.com/week/page/#{page}"
    doc = Nokogiri::HTML(open(url))
    num = rand(20)
    contents = doc.css('.content[title]')
    contents[num].inner_html
  end
end

if __FILE__ == $0
  page = rand(10)
  puts QiuBai.print(page)
end